//
//  CALUtilityTools.h
//  CheckAutoBaseCoreLib
//
//  Created by 孙威 on 15/12/16.
//  Copyright © 2015年 youxinpai. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <AFNetworking.h>

#define CAL_NOTIFICATION_NETWORK_STATUS_CHANGED @"cal_notification_network_status_changed"

#define AutoValue(s, m, l) [Util autoValueLittle:s middle:m large:l]

@interface CALUtilityTools : NSObject

// Unicode 转中文
+ (NSString *)replaceUnicode:(NSString *)unicodeStr;
+ (void)showTips:(NSString *)tips forSecond:(CGFloat)second onView:(UIView *)view;

/**
 *  生成缩略图
 *
 *  @param oldImage 原图
 *  @param factor   比例
 *
 *  @return 缩略图
 */
+ (UIImage *)getThumbFromImage:(UIImage *)oldImage scaleFactor:(CGFloat)factor;

/**
 *  缓存图片到本地
 *
 *  @param imageData 图片数据
 *  @param imageDic  目标路径
 *  @param imageName 图片名称
 *
 *  @return 图片沙盒路径
 */
+ (NSString *)cacheImage:(NSData *)imageData atDic:(NSString *)imageDic withName:(NSString *)imageName;

/**
 *  获取当前时间
 *
 *  @param format 时间格式
 *
 *  @return 时间字符串
 */
+ (NSString *)getCurrentTimeWithFormat:(NSString *)format;

/**
 *  字符串判空 nil、NSNULL、"" 等
 *
 *  @param text 目标字符串
 *
 *  @return 是否
 */
+ (BOOL)isNotEmptyString:(NSString *)text;

+ (long long)fileSizeAtPath:(NSString*) filePath;

+ (CGFloat)fileSizeForDir:(NSString*)folderPath;

+ (BOOL)clearCacheAtPath:(NSString *)filePath;

+ (NSString *)getCurrentDeviceModel;

+ (NSString *)getCurrentDeviceType;

+ (NSData *)bindImageData:(NSData*)jpeg withMetaDataDictionary:(NSDictionary*)dicRef;

+ (NSString *)getDocumentPathFromFilePath:(NSString *)filePath;

/**
 *  更新客户端
 */
+ (void)updateApp;

/**
 *  监听网络变化
 */
+ (void)monitorNetworkStatus;


+ (BOOL)isFileExistForPath:(NSString *)path isDirectory:(BOOL) isDirectory;
+ (BOOL)createEmptyFileAtPath:(NSString *)filePath isDirectory:(BOOL)isDirectory withAttributes:(NSDictionary *) attributes;
+ (BOOL)deleteFileAtPath:(NSString *)filePath;

+ (NSString *)cacheRootPath;
+ (NSString *)docRootPath;

/**
 *  当一个字符串是nil时，返回NSNULL对象
 *
 *  @param string 目标字符串
 *
 *  @return NSNull对象或者字符串
 */
+ (id)getNSNullFromNilIfNecessary:(NSString *)string;

/**
 *  请求相机权限
 */
+ (void)requestCameraAccess;

/**
 *  剪裁图片
 *
 *  @param image 原图
 *  @param size  剪裁后的比例
 *
 *  @return 完成图
 */
+ (UIImage *)imageCompressForSizeImage:(UIImage *)image targetSize:(CGSize)size;

/**
 *  检测系统是否有足够的存储空间
 *
 *  @param size 空间大小
 *
 *  @return 是否
 */
+ (BOOL)haveEnoughSpace:(CGFloat)size;

/**
 *  当前内存使用量
 *
 *  @return 单位 M
 */
+ (double)usedMemory;

/**
 *  获取当前时间戳
 *
 *  @return 时间戳字符串
 */
+ (NSString *)getCurrentTimeInterval;

/**
 *  根据屏幕尺寸返回对应的值
 *
 *  @param little 小屏
 *  @param middle 中屏
 *  @param large  大屏
 *
 *  @return 对应值
 */
+ (CGFloat)autoValueLittle:(CGFloat)little middle:(CGFloat)middle large:(CGFloat)large;

@end
